
package it.polimi.meteocal.entity;

/**
 * Type of messages dependig on the code that identify it
 * 
 */
public enum MessageType {

    INVITATIONMESSAGE, EVENTMODIFICATION, THREEDAY, ONEDAY, DELETION;

    public static String toString(MessageType m) {
        switch (m) {
            case DELETION:
                return "Deletion message";
            case EVENTMODIFICATION:
                return "Event modification message";
            case INVITATIONMESSAGE:
                return "Invitation message";
            case ONEDAY:
                return "One day preannounce message";
            case THREEDAY:
                return "Three day preannounce message";
            default:
                return null;
        }
    }

    public static MessageType formInttoMessageType(int i) {
        switch (i) {
            case 0:
                return (DELETION);
            case 1:
                return (EVENTMODIFICATION);
            case 2:
                return (INVITATIONMESSAGE);
            case 3:
                return (ONEDAY);
            case 4:
                return (THREEDAY);
            default:
                return null;
        }
    }

    public static MessageType fromStringtoMessageType(String s) {
        s = s.toUpperCase();
        switch (s) {
            case "DELETION":
                return (DELETION);
            case "EVENTMODIFICATION":
                return (EVENTMODIFICATION);
            case "INVITATIONMESSAGE":
                return (INVITATIONMESSAGE);
            case "ONEDAY":
                return (ONEDAY);
            case "THREEDAY":
                return (THREEDAY);
            default:
                return null;
        }
    }
}
